/**
 * 该用户发布过的问卷模块
 * @author
 * @date 2012-11-20
 */


var colNames = ['','姓名','标题','时间','ID'];

/**
 * colModel 显示列的属性
 *
 * @type {Object}
 */
var colModel = [
	{ name:'first', index:'first', width:"100%", align:"left", title:false }, 	
	{ name:'userName',index:'userName', hidden:true },  
	{ name:'title',index:'title', hidden:true }, 
	{ name:'formatCreatetime',index:'formatCreatetime', hidden:true },
	{name:'id',index:'id',hidden:true}
];

/**
 * rowNum 想要显示的数据行数
 *
 * @type {Number}
 */

var rowNum = 10;

/**
 * total_last 用于判定表格的总页码是否发生了改变
 *
 * @type {Number}
 */

var total_last = 0;

/**
 * loadDataSuccess 判定是否成功加载完数据
 *
 * @type {Boolean}
 */

var loadDataSuccess = false;

$( "#releasedOf" ).jqGrid({
//	datatype:"local",
//	data:local_data,
	url:'../exam/otherReleasedOfData.html?otherId='+otherId,
	datatype:"json",
	mtype: "POST",
	height: "auto",
	autowidth: true,
	colNames: colNames, 
	colModel: colModel,
	rowNum: rowNum, 
	viewrecords: true,
	emptyrecords : '他很懒,还没有发布过项目',
	pager: 'releasedOfpager', 
	jsonReader: {
		root: "result",
		page: "page",
		total: "total",
		records: "records",
		repeatitems: false,
		cell: "cell",
		id: "id"
	},
	
	gridComplete:function() {
		// 取消外边框
		$( "#gbox_releasedOf" ).css( "border", "none" );
		
		// 隐藏表头
		$( "#gview_releasedOf .ui-jqgrid-hdiv" ).css( "display", "none" );
		
		// 取消列间的分界限
		$( "#gview_releasedOf .ui-jqgrid-bdiv td" ).css( "border-right-style", "none" );

		// 改变底边框样式
		$( "#gview_releasedOf .ui-jqgrid-bdiv tr:not(:first-child) td" ).css( "border-bottom", "1px solid #E5E5E5" );
		
		// 取消最后一行的底边框
		$( "#gview_releasedOf .ui-jqgrid-bdiv tr td" ).css( "border-bottom-style", "none" );
		
		// 设置表格行高
		//$( "#gview_releasedOf .ui-jqgrid-bdiv tr:gt(0)" ).css( "height", "110px" );

		/**
		 * IDs 获取当前页所有数据的id
		 *
		 * @type {Object}
		 */

		var IDs = $( "#releasedOf" ).jqGrid( "getDataIDs" );
		//没有数据
		if(IDs.length==0){
			$("#releasedOfpager_center").hide();
			$(".ui-paging-info").css("text-align","left");
			$(".ui-paging-info").css("font-size","15px");
			$(".ui-jqgrid-view").css("height","60px");
		}
		
		for (var i=0; i < IDs.length; i++) {

			/**
			 * everyRowData 根据某一行数据的id获取该数据所有信息
			 *
			 * @type {Object}
			 */

			var everyRowData = $( "#releasedOf" ).jqGrid( "getRowData", IDs[i] );
			
			// 信息自定义模块
			var metadata ='<p class="form-context" style="background-color:' +(i%2==0?'rgb(248, 248, 248)':'rgb(255, 255, 255)')+';">' +   					
					            '<img src="../images/index/form_icon1.png">' +
					            '<span class="span1">' + everyRowData.userName + '</span>' +
					            '<span class="span2">:</span>' +
					            '<span class="span3"><a href="../ppt/join.html?id='+everyRowData.id+'" title="查看该测试详情">' + everyRowData.title + '</a></span>' +
					            '<span class="span4">'+ everyRowData.formatCreatetime +'</span>' +	
							'</p>';									
			$( "#releasedOf" ).jqGrid( 'setRowData', IDs[i], { first: metadata } );
			// 取消提示信息
			$( ".metadata" ).parent("td").attr("title","");
	
        }		
	},
	onSelectRow: function(rowid) {}

});

